package uit.nfcmenu.models;

import uit.nfcmenu.utils.CommConstant.OrderStates;

public class OrderChef extends OrderModel {

	int time;
	OrderStates state;

	public OrderChef(OrderModel model) {
		super(model);
		time = 0;
		state = OrderStates.valueOf(getStatus().toUpperCase());
	}

	public void update(OrderModel model) {

		super.setComment(model.getComment());
		super.setDescription(model.getDescription());
		super.setItemID(model.getItemID());
		super.setOrderID(model.getOrderID());
		super.setOrderTime(model.getOrderTime());
		super.setQuantity(model.getQuantity());
		super.setStatus(model.getStatus().toUpperCase());
		super.setTableNo(model.getTableNo());
	}

	public int getTime() {
		return time;
	}

	public void setTime(int time) {
		this.time = time;
	}

	public String getTimeRemain() {
		boolean flag = false;
		int temp = time;
		if (time < 0) {
			temp = Math.abs(time);
			flag = true;
		}
		int minutes = temp / 60;
		int second = temp % 60;
		String result = "";
		if (minutes < 10) {
			result = result + "0" + minutes + ":";
		} else {
			result = result + minutes + ":";
		}
		if (second < 10) {
			result = result + "0" + second;
		} else {
			result = result + second;
		}
		if (flag) {
			result = "-" + result;
		}
		return result;
	}

	public String getNextStateString() {
		OrderStates nextState = OrderStates.values()[state.ordinal() + 1];
		return nextState.name();
	}
}
